/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ensisa.sunspot.profile;

import java.io.IOException;
import java.util.Vector;

import fr.ensisa.sunspot.Application;
import fr.ensisa.sunspot.actor.IActor;
import fr.ensisa.sunspot.actor.Template;
import fr.ensisa.sunspot.actor.client.KeyboardActor;
import fr.ensisa.sunspot.actor.client.MouseActor;
import fr.ensisa.sunspot.actor.osc.OscActor;
import fr.ensisa.sunspot.actor.osc.TcpServer;
import fr.ensisa.sunspot.actor.server.ButtonAutomateActor;
import fr.ensisa.sunspot.actor.test.TestActor2;
import fr.ensisa.sunspot.actor.test.TestClient;
import fr.ensisa.sunspot.actor.writer.StrategicWriter;
import fr.ensisa.sunspot.actor.writer.media.ConsoleMedia;
import fr.ensisa.sunspot.actor.writer.strategy.ImmediatWriter;


/**
 *
 * @author michel
 */
public class ProfileFactory {

	private Application application;

    public ProfileFactory (Application application) {
        this.application = application;
    }

    public int getTimeSample () {
//        return 30; fastest with Activator
//        return 25; fastest with only accelerator and RawDelayedWriter
        return 25;
    }

    public Vector<IActor> newActivatorProfile() throws IOException {
        Vector<IActor> p = new Vector<IActor> ();
    //    p.addElement(new RadioReader());
    //    p.addElement(new TestActor());
        p.addElement(new TestActor2());
        StrategicWriter sw = new StrategicWriter();
        sw.setStrategy(new ImmediatWriter(new ConsoleMedia()));
        p.addElement(sw);
        return p;
    }
    
    public Vector<IActor> clientProfile() throws IOException {
        Vector<IActor> p = new Vector<IActor> ();
        p.addElement(new KeyboardActor());
        p.addElement(new MouseActor());
        p.addElement(new TestClient());
        return p;
    }
    
    public Vector<IActor> serverProfile() {
    	try {
			new Thread(new TcpServer(this.application.getActorManager())).start();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
    	
    	Vector<IActor> p = new Vector<IActor>();
    	
    	StrategicWriter sw = new StrategicWriter();
        sw.setStrategy(new ImmediatWriter(new ConsoleMedia()));
        p.addElement(sw);
        
    	return p;
    }
    
    public Vector<IActor> desktopProfile() {
    	Vector<IActor> p = new Vector<IActor>();
    	
    	p.addElement(new TestActor2());
        
        StrategicWriter sw = new StrategicWriter();
        sw.setStrategy(new ImmediatWriter(new ConsoleMedia()));
        p.addElement(sw);
    	
        OscActor oscActor = new OscActor(null, new Template());
        p.addElement(oscActor);
   
    	return p;
    }
    
    public Vector<IActor> automateTest() {
    	Vector<IActor> p = new Vector<IActor>();
    	
    	p.addElement(new TestClient());
        
        StrategicWriter sw = new StrategicWriter();
        sw.setStrategy(new ImmediatWriter(new ConsoleMedia()));
 //       p.addElement(sw);
    	
        p.addElement(new ButtonAutomateActor());
   
    	return p;   	
    }
}
